{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-page">
	<div class="layui-card">
        <div class="layui-card-header"><h3>成绩统计</h3></div>
        <div class="layui-card-body">
          <table class="layui-table layui-table-min">
				<tr>
					<th width="100">试卷总分</th>
					<th width="100">优秀分数</th>
					<th width="100">及格分数</th>
					<th width="100">考试时长</th>
					<th width="100">考试记录</th>
					<th width="100">已审阅</th>
					<th width="100">未审阅</th>
					<th width="100">平均分</th>
					<th width="100">优秀人数</th>
					<th width="100">优秀率</th>
					<th width="100">及格人数</th>
					<th width="100">及格率</th>
				</tr>
				<tr>
					<td class="red">{$detail.total_score}</td>
					<td class="blue">{$detail.good_score}</td>
					<td class="green">{$detail.pass_score}</td>
					<td>{:getTimeBySec($detail.duration)}</td>
					<td>{$record_total}</td>
					<td class="green">{$record_check_1}</td>
					<td class="red">{$record_check_0}</td>
					<td>{$record_avg_score}</td>
					<td class="blue">{$record_good}</td>
					<td class="blue">{$record_good_pesent}%</td>
					<td class="green">{$record_pass}</td>
					<td class="green">{$record_pass_pesent}%</td>
				</tr>
			</table>
        </div>
      </div>
	
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="toolbarDemo">
	<h3>考试记录</h3>
</script>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
	<script>
	const moduleInit = ['tool','tablePlus'];
	const paper_id = {$detail.id};
	function gouguInit() {
		var table = layui.tablePlus, tool = layui.tool, form = layui.form;
		layui.pageTable = table.render({
			elem: '#test'
			,toolbar: '#toolbarDemo'
			,title:'考试记录列表'
			,url: "/exam/record/datalist"
			,where:{id:paper_id}
			,page: true
			,cellMinWidth: 80
			,cols: [[
				{field:'uid',width:80, title: '学员ID', align:'center'}
				,{field:'user_name',width:80,align:'center',title: '学员姓名'}
				,{field:'create_time',width:136,align:'center', title: '考试时间'}
				,{field:'duration',align:'center',width:120,title: '考试耗时'}
				,{field:'score',width:80,align:'center', title: '考试得分',templet: function(d){
					if(d.status==1){
						return d.score;
					}
					else{
						return '-';
					}
				}}
				,{field:'is_pass',width:80,align:'center',title: '是否及格',templet: function(d){
					if(d.status==1){
						if(d.score>=d.pass_score){
							return '<span class="green">及格</span>';
						}
						else{
							return '<span class="red">不及格</span>';
						}
					}
					else{
						return '-';
					}
				}}
				,{field:'department',minWidth:150, title: '学员所在部门'}
				,{field:'position',width:100,align:'center',title: '学员职称'}
				,{field:'status',width:80,align:'center',title: '状态',templet: function(d){
					if(d.status == 0){
						return '<span class="yellow">待审阅</span>';
					}
					if(d.status == 1){
						return '<span class="green">已审阅</span>';
					}
					if(d.status == 2){
						return '<span class="red">审核拒绝</span>';
					}
				}}
				,{field:'reviewer_name',width:80,align:'center',title: '审阅人'}
				,{field:'reviewer_time',width:136,align:'center',title: '审阅时间'}
				,{width:200,fixed:'right', title: '操作', align:'center',ignoreExport:true,templet: function(d){
					let btn1 = '<a class="layui-btn layui-btn-xs" lay-event="check">审阅试卷</a>';
					let btn2 = '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除记录</a>';
					let btn3 = '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="view">考试详情</a>';
					if(d.status == 0){
						return '<div class="layui-btn-group">'+btn1+btn2+btn3+'</div>';
					}
					else{
						return '<div class="layui-btn-group">'+btn2+btn3+'</div>';
					}					
				}}
			]]
		});
		
		table.on('tool(test)',function (obj) {
			if(obj.event === 'check'){		
				tool.side("/exam/record/set?id="+obj.data.id);
			}
			if(obj.event === 'view'){		
				tool.side("/exam/record/view?id="+obj.data.id);
			}
			if(obj.event === 'delete'){		
				let callback = function (e) {
					layer.msg(e.msg);
					if(e.code==0){
						layui.pageTable.reload();
					}
				}
				tool.ask('确定要删除该学员的考试记录吗?', function(index){
					tool.delete("/exam/record/del", {id:obj.data.id}, callback);
					layer.close(index);
				});
			}
			return false;
		})
	}
	</script>
{/block}
<!-- /脚本 -->